package basic.thread.again;

/**重入锁
 *
 * @author bingo
 * @create 2018-02-20 11:44
 **/
public class Demo7 {

    public synchronized void a(){

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"a");
        b();
    }
    public synchronized  void b(){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(Thread.currentThread().getName()+"b");
    }
    public static void main(String[] args) {
        Demo7 demo7 = new Demo7();
        Demo7 demo71 = new Demo7();
      new Thread(new Runnable() {
          @Override
          public void run() {
              demo7.a();

          }
      }).start();
      new Thread(new Runnable() {
          @Override
          public void run() {
              demo71.b();
          }
      }).start();
    }
}
